use strict;
use warnings;

ObjectTest->runtests;


package ObjectTest;
use base qw/Test::Class/;
use Test::More;
use File::Basename;

use MT::App::Test;

sub init_app : Test(setup) {
	my $self = shift;
	$self->{app} = MT::App::Test->test_instance_of(
		#force_initialize_database => 1,
		data_dirs => dirname(File::Spec->rel2abs(__FILE__)),
	);
}

sub object_test : Test(4) {
	my $self = shift;
	my $app = $self->{app};

	my $entry_class = $app->test_model('entry');

	my $yaml_file = File::Spec->catfile(
		dirname(__FILE__), 'volatiles', 'entry.yaml'
	);
	my $yaml = YAML::Tiny->read($yaml_file);
	my $data = $yaml->[0];

	my $to_save = $entry_class->test_load_volatiles('to_save');
	foreach my $k (keys %{ $data->{'to_save'} }) {
		is($to_save->$k, $data->{'to_save'}{$k}, "volatile objects's " . $k);
	}
	ok(! $to_save->id, "volatile objects's id");
}
